﻿namespace ClassyBlog.Infrastructure
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    public abstract class Formatter : IFormatter
    {
        protected Formatter(IEnumerable<string> supportedTypes)
        {
            if (supportedTypes == null)
            {
                throw new ArgumentNullException("supportedTypes");
            }

            SupportedTypes = supportedTypes;
        }

        protected IEnumerable<string> SupportedTypes { get; private set; }

        public virtual bool Supports(string type)
        {
            var result = SupportedTypes.Contains(
                type, StringComparer.OrdinalIgnoreCase);

            return result;
        }

        public abstract string Format(string value);
    }
}